package com.atguigu.gmall.controller;

import com.atguigu.gmall.client.service.OrderFeignClientService;
import com.atguigu.gmall.entity.OrderInfo;
import com.atguigu.gmall.result.RetVal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class WebPaymentController {

    @Autowired
    private OrderFeignClientService orderFeignClientService;

    //点击提交订单之后，页面会发送get请求，并携带订单的id，转到预支付界面
    @GetMapping("pay.html")
    public String payOrder(@RequestParam Long orderId, Model model){
        OrderInfo orderInfo = orderFeignClientService.findOrderById(orderId);//查询订单信息
        model.addAttribute("orderInfo", orderInfo);
        return "payment/pay";
    }
    //支付成功的回调页面
    @GetMapping("alipay/success.html")
    public String success(){
        return "payment/success";
    }

}
